package com.spring.http;

import com.spring.utils.HttpProtocolUtil;

import java.io.IOException;

/**
 * @author Spring King
 * @date 2021/7/10
 */
public class KingHttpServlet extends HttpServlet {

    @Override
    public void doGet(Request request, Response response) {
        String content = "<h1>KingServlet do get</h1>";
        try {
            response.output(HttpProtocolUtil.getHttpHeader200(content.getBytes().length) + content);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void doPost(Request request, Response response) {
        String content = "<h1>KingServlet do post</h1>";
        try {
            response.output(HttpProtocolUtil.getHttpHeader200(content.getBytes().length) + content);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void init() {

    }

    @Override
    public void destroy() {

    }
}
